package com.zqh.cli.command;
import cn.hutool.core.bean.BeanUtil;
import com.zqh.generator.MainGenerator;
import com.zqh.model.MainTemplateConfig;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import picocli.CommandLine;
import picocli.CommandLine.*;

import java.util.concurrent.Callable;

@Command(name = "generate",mixinStandardHelpOptions = true,description = "生成代码")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class GenerateCommand implements Callable<Integer> {

    @Option(names = {"-l","--loop"},arity = "0..1",description = "是否循环",interactive = true,echo = true)
    private boolean loop;
    @Option(names = {"-a","--author"},arity = "0..1",description = "作者注释",interactive = true,echo = true)
    private String author;

    @Option(names = {"-o","--outputText"},arity = "0..1",description = "输出信息",interactive = true,echo = true)
    private String outputText;


    @Override
    public Integer call() throws Exception {

        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this,mainTemplateConfig);
        System.out.println(this.loop);
        System.out.println(mainTemplateConfig.getAuthor());
        System.out.println("配置信息：" + mainTemplateConfig);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
